package com.example.controller;

import com.example.model.Product;
import com.example.service.CategoryService;
import com.example.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;
@Controller
@RequestMapping
public class CategoryController {

    @Autowired
    ProductService productService;
    @GetMapping("/category")
    public String category(Integer id,  String sort, Model model) throws Exception {
        List<Product> pro = productService.proList(id);//根据路径提供的种类ID得到对应的产品队列

        model.addAttribute("product",pro);
        return "category";
    }
}
